package com.demo.springbootdemo.controller;

import com.demo.springbootdemo.config.Counter;
import com.demo.springbootdemo.properties.Demo;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

@RestController()
@RequestMapping("hello")
@RequiredArgsConstructor
public class HelloController {
    private final Demo demo;
    @GetMapping("entry")
    public Demo entry(String address) {
        demo.setAge(18);
        if (address != null) {
            demo.setAddress(address);
        } else {
            demo.setAddress("测试地址");
        }
        return demo;
    }

    @PostMapping("test")
    public Demo test(@RequestBody Demo demo) {
        return demo;
    }

    @GetMapping("count")
    public int count() {
        Counter.count++;
        return Counter.count;
    }
}
